package interview.aba;

import java.util.concurrent.atomic.AtomicInteger;

public class ABAQuestion {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger atomicInteger = new AtomicInteger(100);
        new Thread(()->{
            atomicInteger.compareAndSet(100,101);
            atomicInteger.compareAndSet(101,100);
            System.out.println("ABA操作完毕！");
        }," T1").start();
        new Thread(()->{
           boolean isOK = atomicInteger.compareAndSet(100,101);
            System.out.println("isOK:"+isOK);
        }," T2").start();
    }
}
